summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nfc/nfc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/nfc/nfc.cpp')
-rw-r--r--src/core/hle/service/nfc/nfc.cpp125
1 files changed, 65 insertions, 60 deletions
diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp
index 444d65f07..30ae989b9 100644
--- a/src/core/hle/service/nfc/nfc.cpp
+++ b/src/core/hle/service/nfc/nfc.cpp
@@ -6,7 +6,6 @@
#include "common/logging/log.h"
#include "common/settings.h"
#include "core/hle/service/ipc_helpers.h"
-#include "core/hle/service/nfc/mifare_interface.h"
#include "core/hle/service/nfc/nfc.h"
#include "core/hle/service/nfc/nfc_interface.h"
#include "core/hle/service/server_manager.h"
@@ -14,31 +13,31 @@
namespace Service::NFC {
-class IUser final : public Interface {
+class IUser final : public NfcInterface {
public:
- explicit IUser(Core::System& system_) : Interface(system_, "NFC::IUser") {
+ explicit IUser(Core::System& system_) : NfcInterface(system_, "NFC::IUser", BackendType::Nfc) {
// clang-format off
static const FunctionInfo functions[] = {
- {0, &Interface::Initialize, "InitializeOld"},
- {1, &Interface::Finalize, "FinalizeOld"},
- {2, &Interface::GetState, "GetStateOld"},
- {3, &Interface::IsNfcEnabled, "IsNfcEnabledOld"},
- {400, &Interface::Initialize, "Initialize"},
- {401, &Interface::Finalize, "Finalize"},
- {402, &Interface::GetState, "GetState"},
- {403, &Interface::IsNfcEnabled, "IsNfcEnabled"},
- {404, &Interface::ListDevices, "ListDevices"},
- {405, &Interface::GetDeviceState, "GetDeviceState"},
- {406, &Interface::GetNpadId, "GetNpadId"},
- {407, &Interface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"},
- {408, &Interface::StartDetection, "StartDetection"},
- {409, &Interface::StopDetection, "StopDetection"},
- {410, &Interface::GetTagInfo, "GetTagInfo"},
- {411, &Interface::AttachActivateEvent, "AttachActivateEvent"},
- {412, &Interface::AttachDeactivateEvent, "AttachDeactivateEvent"},
- {1000, nullptr, "ReadMifare"},
- {1001, nullptr, "WriteMifare"},
- {1300, &Interface::SendCommandByPassThrough, "SendCommandByPassThrough"},
+ {0, &NfcInterface::Initialize, "InitializeOld"},
+ {1, &NfcInterface::Finalize, "FinalizeOld"},
+ {2, &NfcInterface::GetState, "GetStateOld"},
+ {3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"},
+ {400, &NfcInterface::Initialize, "Initialize"},
+ {401, &NfcInterface::Finalize, "Finalize"},
+ {402, &NfcInterface::GetState, "GetState"},
+ {403, &NfcInterface::IsNfcEnabled, "IsNfcEnabled"},
+ {404, &NfcInterface::ListDevices, "ListDevices"},
+ {405, &NfcInterface::GetDeviceState, "GetDeviceState"},
+ {406, &NfcInterface::GetNpadId, "GetNpadId"},
+ {407, &NfcInterface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"},
+ {408, &NfcInterface::StartDetection, "StartDetection"},
+ {409, &NfcInterface::StopDetection, "StopDetection"},
+ {410, &NfcInterface::GetTagInfo, "GetTagInfo"},
+ {411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"},
+ {412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"},
+ {1000, &NfcInterface::ReadMifare, "ReadMifare"},
+ {1001, &NfcInterface::WriteMifare ,"WriteMifare"},
+ {1300, &NfcInterface::SendCommandByPassThrough, "SendCommandByPassThrough"},
{1301, nullptr, "KeepPassThroughSession"},
{1302, nullptr, "ReleasePassThroughSession"},
};
@@ -48,34 +47,35 @@ public:
}
};
-class ISystem final : public Interface {
+class ISystem final : public NfcInterface {
public:
- explicit ISystem(Core::System& system_) : Interface{system_, "NFC::ISystem"} {
+ explicit ISystem(Core::System& system_)
+ : NfcInterface{system_, "NFC::ISystem", BackendType::Nfc} {
// clang-format off
static const FunctionInfo functions[] = {
- {0, &Interface::Initialize, "InitializeOld"},
- {1, &Interface::Finalize, "FinalizeOld"},
- {2, &Interface::GetState, "GetStateOld"},
- {3, &Interface::IsNfcEnabled, "IsNfcEnabledOld"},
+ {0, &NfcInterface::Initialize, "InitializeOld"},
+ {1, &NfcInterface::Finalize, "FinalizeOld"},
+ {2, &NfcInterface::GetState, "GetStateOld"},
+ {3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"},
{100, nullptr, "SetNfcEnabledOld"},
- {400, &Interface::Initialize, "Initialize"},
- {401, &Interface::Finalize, "Finalize"},
- {402, &Interface::GetState, "GetState"},
- {403, &Interface::IsNfcEnabled, "IsNfcEnabled"},
- {404, &Interface::ListDevices, "ListDevices"},
- {405, &Interface::GetDeviceState, "GetDeviceState"},
- {406, &Interface::GetNpadId, "GetNpadId"},
- {407, &Interface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"},
- {408, &Interface::StartDetection, "StartDetection"},
- {409, &Interface::StopDetection, "StopDetection"},
- {410, &Interface::GetTagInfo, "GetTagInfo"},
- {411, &Interface::AttachActivateEvent, "AttachActivateEvent"},
- {412, &Interface::AttachDeactivateEvent, "AttachDeactivateEvent"},
+ {400, &NfcInterface::Initialize, "Initialize"},
+ {401, &NfcInterface::Finalize, "Finalize"},
+ {402, &NfcInterface::GetState, "GetState"},
+ {403, &NfcInterface::IsNfcEnabled, "IsNfcEnabled"},
+ {404, &NfcInterface::ListDevices, "ListDevices"},
+ {405, &NfcInterface::GetDeviceState, "GetDeviceState"},
+ {406, &NfcInterface::GetNpadId, "GetNpadId"},
+ {407, &NfcInterface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"},
+ {408, &NfcInterface::StartDetection, "StartDetection"},
+ {409, &NfcInterface::StopDetection, "StopDetection"},
+ {410, &NfcInterface::GetTagInfo, "GetTagInfo"},
+ {411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"},
+ {412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"},
{500, nullptr, "SetNfcEnabled"},
{510, nullptr, "OutputTestWave"},
- {1000, nullptr, "ReadMifare"},
- {1001, nullptr, "WriteMifare"},
- {1300, &Interface::SendCommandByPassThrough, "SendCommandByPassThrough"},
+ {1000, &NfcInterface::ReadMifare, "ReadMifare"},
+ {1001, &NfcInterface::WriteMifare, "WriteMifare"},
+ {1300, &NfcInterface::SendCommandByPassThrough, "SendCommandByPassThrough"},
{1301, nullptr, "KeepPassThroughSession"},
{1302, nullptr, "ReleasePassThroughSession"},
};
@@ -85,25 +85,29 @@ public:
}
};
+// MFInterface has an unique interface but it's identical to NfcInterface so we can keep the code
+// simpler
+using MFInterface = NfcInterface;
class MFIUser final : public MFInterface {
public:
- explicit MFIUser(Core::System& system_) : MFInterface{system_, "NFC::MFInterface"} {
+ explicit MFIUser(Core::System& system_)
+ : MFInterface{system_, "NFC::MFInterface", BackendType::Mifare} {
// clang-format off
- static const FunctionInfo functions[] = {
+ static const FunctionInfoTyped<MFIUser> functions[] = {
{0, &MFIUser::Initialize, "Initialize"},
{1, &MFIUser::Finalize, "Finalize"},
{2, &MFIUser::ListDevices, "ListDevices"},
{3, &MFIUser::StartDetection, "StartDetection"},
{4, &MFIUser::StopDetection, "StopDetection"},
- {5, &MFIUser::Read, "Read"},
- {6, &MFIUser::Write, "Write"},
+ {5, &MFIUser::ReadMifare, "Read"},
+ {6, &MFIUser::WriteMifare, "Write"},
{7, &MFIUser::GetTagInfo, "GetTagInfo"},
- {8, &MFIUser::GetActivateEventHandle, "GetActivateEventHandle"},
- {9, &MFIUser::GetDeactivateEventHandle, "GetDeactivateEventHandle"},
+ {8, &MFIUser::AttachActivateEvent, "GetActivateEventHandle"},
+ {9, &MFIUser::AttachDeactivateEvent, "GetDeactivateEventHandle"},
{10, &MFIUser::GetState, "GetState"},
{11, &MFIUser::GetDeviceState, "GetDeviceState"},
{12, &MFIUser::GetNpadId, "GetNpadId"},
- {13, &MFIUser::GetAvailabilityChangeEventHandle, "GetAvailabilityChangeEventHandle"},
+ {13, &MFIUser::AttachAvailabilityChangeEvent, "GetAvailabilityChangeEventHandle"},
};
// clang-format on
@@ -131,7 +135,7 @@ public:
explicit NFC_AM(Core::System& system_) : ServiceFramework{system_, "nfc:am"} {
// clang-format off
static const FunctionInfo functions[] = {
- {0, &NFC_AM::CreateAmInterface, "CreateAmInterface"},
+ {0, &NFC_AM::CreateAmNfcInterface, "CreateAmNfcInterface"},
};
// clang-format on
@@ -139,7 +143,7 @@ public:
}
private:
- void CreateAmInterface(HLERequestContext& ctx) {
+ void CreateAmNfcInterface(HLERequestContext& ctx) {
LOG_DEBUG(Service_NFC, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -153,7 +157,7 @@ public:
explicit NFC_MF_U(Core::System& system_) : ServiceFramework{system_, "nfc:mf:u"} {
// clang-format off
static const FunctionInfo functions[] = {
- {0, &NFC_MF_U::CreateUserInterface, "CreateUserInterface"},
+ {0, &NFC_MF_U::CreateUserNfcInterface, "CreateUserNfcInterface"},
};
// clang-format on
@@ -161,7 +165,7 @@ public:
}
private:
- void CreateUserInterface(HLERequestContext& ctx) {
+ void CreateUserNfcInterface(HLERequestContext& ctx) {
LOG_DEBUG(Service_NFC, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -175,7 +179,7 @@ public:
explicit NFC_U(Core::System& system_) : ServiceFramework{system_, "nfc:user"} {
// clang-format off
static const FunctionInfo functions[] = {
- {0, &NFC_U::CreateUserInterface, "CreateUserInterface"},
+ {0, &NFC_U::CreateUserNfcInterface, "CreateUserNfcInterface"},
};
// clang-format on
@@ -183,7 +187,7 @@ public:
}
private:
- void CreateUserInterface(HLERequestContext& ctx) {
+ void CreateUserNfcInterface(HLERequestContext& ctx) {
LOG_DEBUG(Service_NFC, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -197,7 +201,7 @@ public:
explicit NFC_SYS(Core::System& system_) : ServiceFramework{system_, "nfc:sys"} {
// clang-format off
static const FunctionInfo functions[] = {
- {0, &NFC_SYS::CreateSystemInterface, "CreateSystemInterface"},
+ {0, &NFC_SYS::CreateSystemNfcInterface, "CreateSystemNfcInterface"},
};
// clang-format on
@@ -205,7 +209,7 @@ public:
}
private:
- void CreateSystemInterface(HLERequestContext& ctx) {
+ void CreateSystemNfcInterface(HLERequestContext& ctx) {
LOG_DEBUG(Service_NFC, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@@ -221,6 +225,7 @@ void LoopProcess(Core::System& system) {
server_manager->RegisterNamedService("nfc:mf:u", std::make_shared<NFC_MF_U>(system));
server_manager->RegisterNamedService("nfc:user", std::make_shared<NFC_U>(system));
server_manager->RegisterNamedService("nfc:sys", std::make_shared<NFC_SYS>(system));
+
ServerManager::RunServer(std::move(server_manager));
}